package com.k.lib_view

import android.view.View
import android.widget.Toast
import androidx.activity.viewModels
import com.k.lib_base.BaseActivity
import com.k.lib_base.BaseViewModel
import com.k.lib_view.databinding.ActivityTestBinding
import com.k.lib_viewmodel.TestViewModel

class TestActivity : BaseActivity<ActivityTestBinding>() {
    private val vm by viewModels<TestViewModel>()

    override fun layoutId(): Int {
        return R.layout.activity_test
    }

    override fun initView() {
        mBinding?.run {
            tvm = vm
            testClick = View.OnClickListener {
                vm.test()
            }
        }

        initListener()
    }

    private fun initListener() {
        vm.loadStauts.observe(this) {
            when (it) {
                BaseViewModel.LoadStauts.LOADING -> {}
                BaseViewModel.LoadStauts.SUCCESS -> {
                    Toast.makeText(this, vm.message, Toast.LENGTH_SHORT).show()
                }

                BaseViewModel.LoadStauts.ERROR -> {}
                BaseViewModel.LoadStauts.TIP -> {}
            }
        }
    }

}